package com.pospi.xstore.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Qiyan on 2016/7/20.
 */
public class DB extends SQLiteOpenHelper {
    private String goods="goods";
    public  final String CREATE_Goods = "create table if not exists "+goods+"("
            + "id integer primary key autoincrement,code text,"
            + "name text,category_sid text,image text,colorCodeShow text,"
            + "price double,discount double,group_sid text,unit text,sid text,spec text，" +
            "dzc text)";

    String menuinfo = "menuinfo";
    /**
     * 订单信息，需要店铺的信息和收银员的信息
     */
    public final String CREATE_Menu = "create table if not exists " +menuinfo+ "("
            + "id integer primary key autoincrement,Sid text,name text,colorCode text,"
            + "orderBy text)";

    String orderinfo = "orderinfo";
    /**
     * 订单信息，需要店铺的信息和收银员的信息
     */
    public final String CREATE_Order = "create table if not exists " + orderinfo + "("
            + "id integer primary key autoincrement,maxNo integer,orderType integer,payway text,"
            + "shop_id text,time text,ss_money double,ys_money double,zl_money double,"
            + "order_info text,cashiername text,cashiernumber text,detailTime text," +
            "checkoutTime text,hasReturnGoods integer,out_trade_no text," +
            "payReturn text,ifFinishOrder integer,searchTime integer," +
            "tableNumber text,tableId text,vipNumber text)";
    private String tableModifiedGroup = "modifiedgroup_info";
    private String tableModified = "modified_info";
    /**
     * 创建做法组表格
     */
    public final String CREATE_ModifiedGroup_Table = "create table if not exists " + tableModifiedGroup + "("
            + "id integer primary key autoincrement,Sid text,"
            + "Uid text,Name text,CreateTime text,option text,"
            + "orderBy text,option_bool double)";

    /**
     * 创建做法表格
     */
    public final String CREATE_Modified_Table = "create table if not exists " + tableModified + "("
            + "id integer primary key autoincrement,Sid text,"
            + "Uid text,Name text,GroupSid text,Price double,"
            + "CostPrice double,image text,unit text,colorCode text,"
            + "CreateTime text,orderBy text,colorCodeShow text)";


    public DB(Context context) {
        super(context,"pospiHold.db", null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_Goods);
        db.execSQL(CREATE_Order);
        db.execSQL(CREATE_Menu);
        db.execSQL(CREATE_Modified_Table);
        db.execSQL(CREATE_ModifiedGroup_Table);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
